/*            Copyright(c) 2006-2008 Dave Sexton           *
 * http://www.codeplex.com/DocProject                      *
 * http://www.codeplex.com/DocProject/Project/License.aspx *
 ***********************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using DaveSexton.Controls;
using DaveSexton.DocProject.Sandcastle.ContentManagement;

namespace DaveSexton.DocProject.Sandcastle.TopicManagement
{
	[Serializable]
	internal sealed class ConceptualTopicSectionsDocument : XmlContentDocument
	{
		#region Public Properties
		[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1802:UseLiteralsWhereAppropriate")]
		public static readonly string VirtualDocumentName = "virtual_conceptual_document";
		#endregion

		#region Private / Protected
		[NonSerialized]
		private readonly IXmlTopic topic;
		#endregion

		#region Constructors
		/// <summary>
		/// Constructs a new instance of the <see cref="ConceptualTopicSectionsDocument" /> class.
		/// </summary>
		public ConceptualTopicSectionsDocument(IXmlTopic topic)
			: base(VirtualDocumentName)
		{
			this.topic = topic;
		}
		#endregion

		#region Methods
		protected internal override void NotifyItemChanged(ContentItem item)
		{
			topic.NotifySectionChanged(item.Name);

			base.NotifyItemChanged(item);
		}

		public override ContentItem CreateItem(string name)
		{
			throw new NotSupportedException();
		}

		public override void Load(Importer rebaseTargetDirectory, HtmlToXmlConverterCallback converter)
		{
			throw new NotSupportedException();
		}

		public override void Save()
		{
			throw new NotSupportedException();
		}

		public override void Save(string targetPath)
		{
			throw new NotSupportedException();
		}

		public override void Commit()
		{
			foreach (ConceptualTopicContentItem item in Items)
				item.CommitChanges();
		}

		public override void Cancel()
		{
			foreach (ConceptualTopicContentItem item in Items)
				item.CancelChanges();
		}
		#endregion
	}
}
